using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Babushka.GameModels.Tiles
{
    class UnresponsiveTile : Tile
    {
        private bool _isInMainTiles;
        private Texture2D customTexture;
        private readonly int texturePosX;

        private readonly int texturePosY;

        public UnresponsiveTile(int texturePosX, int texturePosY)
        {
            this.texturePosY = texturePosY;
            this.texturePosX = texturePosX;
            _isInMainTiles = true;
        }

        public UnresponsiveTile(Texture2D texture)
        {
            customTexture = texture;
        }

        public override Rectangle GetBoundingBox(int x, int y)
        {
            return new Rectangle(x * Tile.TileSize, y * Tile.TileSize, Tile.TileSize, Tile.TileSize);
        }

        public override void DrawTile(int x, int y)
        {
            Vector2 pos = new Vector2(Tile.TileSize);
            pos.X *= x;
            pos.Y *= y;
            if (_isInMainTiles)
            {
                Rectangle srcRect = new Rectangle();
                srcRect.X = texturePosX * Tile.TileSize;
                srcRect.Y = texturePosY * Tile.TileSize;
                srcRect.Width = srcRect.Height = Tile.TileSize;
                Game1.SpriteBatch.Draw(Resources.Graphics.Tiles, pos, srcRect, Color.White);
            }
            else
            {
                Game1.SpriteBatch.Draw(customTexture, pos, Color.White);
            }
        }
    }
}